package com.linkoog.devtools.project_manager.everywhere;

import com.intellij.openapi.util.NlsSafe;
import com.intellij.navigation.ItemPresentation;
import org.jetbrains.annotations.Nullable;
import com.intellij.icons.AllIcons;
import javax.swing.Icon;
import com.intellij.navigation.NavigationItem;

public class ProjectManagerNavigationItem implements NavigationItem {
    private final String projectName;
    private final String projectPath;
    private final Icon icon;
    private final boolean isOpen;

    public ProjectManagerNavigationItem(final String projectName, final String projectPath) {
        this(projectName, projectPath, false);
    }

    public ProjectManagerNavigationItem(final String projectName, final String projectPath, final boolean isOpen) {
        this.projectName = projectName;
        this.projectPath = projectPath;
        this.isOpen = isOpen;
        this.icon = AllIcons.Nodes.Module;
    }

    
    public boolean isOpen() {
        return this.isOpen;
    }
    
    public String getProjectName() {
        return this.projectName;
    }
    
    public Icon getIcon() {
        return this.icon;
    }
    
    public String getProjectPath() {
        return this.projectPath;
    }
    
    @Nullable
    public String getName() {
        return this.projectName;
    }
    
    @Nullable
    public ItemPresentation getPresentation() {
        return new ItemPresentation() {
            @NlsSafe
            public String getPresentableText() {
                return isOpen? projectName + " (opened)" : projectName + " - " + projectPath;
            }
            
            public Icon getIcon(final boolean unused) {
                return icon;
            }
        };
    }
    
    public void navigate(final boolean requestFocus) {
    }
    
    public boolean canNavigate() {
        return true;
    }
    
    public boolean canNavigateToSource() {
        return true;
    }
    
    @Override
    public String toString() {
        return (this.isOpen ? "[current] " : "[recent] ") + this.projectPath;
    }
}
